package com.zxl.app.controller.goods;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageInfo;
import com.zxl.common.Page;
import com.zxl.common.Result;
import com.zxl.common.constant.CommonStatusConstant;
import com.zxl.common.model.pojo.SysGoodsType;
import com.zxl.common.model.vo.goods.GoodsLabelVo;
import com.zxl.common.service.SysGoodsTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zxw
 * @date 2023/4/3
 */
@RestController
@RequestMapping("/app/goods_type")
@Slf4j
@Api(tags = {"商品分类模块"})
public class GoodsTypeController {
    @Resource
    private SysGoodsTypeService sysGoodsTypeService;

    @ApiOperation("商品分类标签")
    @GetMapping("/label")
    public Result<List<GoodsLabelVo>> label(){
        List<SysGoodsType> list = sysGoodsTypeService.list(new QueryWrapper<SysGoodsType>()
                .eq("status", CommonStatusConstant.ADOPT.getCode())
                .orderByAsc("sequence"));
        Page<SysGoodsType> page = Page.pageInfoConvert(new PageInfo(list));
        return new Result(page);
    }
}
